package com.mapull.example.section1;

import org.apache.commons.lang3.StringUtils;

/**
 * @author mapull
 * @date 2024-03-16
 */
public class StringTrim {


    public static void main(String[] args) {
        String base = "我爱 JAVA 编程";
        String text = "我爱 JAVA 编程\u2001";
        String stripText = text.trim();
        String sstripText = StringUtils.strip(text);
        System.out.println( text + "strip前后 " + stripText.equals(base));
        System.out.println( text + "strip前后 " + sstripText.equals(base));
    }
        public static void main2(String[] args) {
        String base = "我爱 JAVA 编程";
        String text = " 我爱 JAVA 编程 ";
        String trimText = text.trim();
        System.out.println("前后含有空格，trim前后 " + trimText.equals(base));

        String text2 = "我爱 JAVA 编程\n";
        String trimText2 = text2.trim();
        System.out.println("前后含有空格，trim前后 " + trimText2.equals(base));

        String text3 = "我爱 JAVA 编程\r";
        String trimText3 = text3.trim();
        System.out.println("前后含有空格，trim前后 " + trimText3.equals(base));

        String text4 = "我爱 JAVA 编程\t";
        String trimText4 = text4.trim();
        System.out.println("前后含有空格，trim前后 " + trimText4.equals(base));
    }
}
